home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Kant Generator Pro 1.2 / src / Shell ƒ / edit functions.c < prev    next >
C/C++ Source or Header  |  1995-01-31  |  3KB  |  111 lines

  1. #include "edit functions.h"
  2. #include "drag utilities.h"
  3. #include "text twiddling.h"
  4. #include "window layer.h"
  5.  
  6. void GenericCut(WindowPtr theWindow)
  7. {
  8.     TEHandle        hTE;
  9.     ControlHandle    vScrollBar;
  10.     
  11.     hTE=GetWindowTE(theWindow);
  12.     vScrollBar=GetWindowVScrollBar(theWindow);
  13.     if (AnyHighlightedQQ(theWindow))
  14.         SetWindowIsModified(theWindow, TRUE);
  15.     TECut(hTE);
  16.     ZeroScrap();
  17.     TEToScrap();
  18.     if (vScrollBar!=0L)
  19.         AdjustForEndScroll(vScrollBar, hTE);
  20.     TESelView(hTE);
  21.     if (vScrollBar!=0L)
  22.         AdjustVScrollBar(vScrollBar, hTE);
  23.     SetWindowLastFindPosition(theWindow, (**hTE).selStart);
  24.     ResetHiliteRgn(theWindow);
  25. }
  26.  
  27. void GenericCopy(WindowPtr theWindow)
  28. {
  29.     TEHandle        hTE;
  30.     ControlHandle    vScrollBar;
  31.     
  32.     hTE=GetWindowTE(theWindow);
  33.     vScrollBar=GetWindowVScrollBar(theWindow);
  34.     TECopy(hTE);
  35.     ZeroScrap();
  36.     TEToScrap();
  37.     TESelView(hTE);
  38.     if (vScrollBar!=0L)
  39.         AdjustVScrollBar(vScrollBar, hTE);
  40.     SetWindowLastFindPosition(theWindow, (**hTE).selStart);
  41.     ResetHiliteRgn(theWindow);
  42. }
  43.  
  44. void GenericPaste(WindowPtr theWindow)
  45. {
  46.     TEHandle        hTE;
  47.     ControlHandle    vScrollBar;
  48.     Handle            scrapHandle;
  49.     long            dummy;
  50.     unsigned long    scrapLength;
  51.     
  52.     hTE=GetWindowTE(theWindow);
  53.     vScrollBar=GetWindowVScrollBar(theWindow);
  54.     scrapHandle=NewHandle(0L);
  55.     if (GetScrap(scrapHandle, 'TEXT', &dummy)!=noTypeErr)
  56.     {
  57.         scrapLength=GetHandleSize(scrapHandle);
  58.         if (scrapLength+(**hTE).teLength>32767)
  59.         {
  60.             SysBeep(7);
  61.             return;
  62.         }
  63.         
  64.         if (scrapLength!=0L)
  65.             SetWindowIsModified(theWindow, TRUE);
  66.         TEFromScrap();
  67.         TEPaste(hTE);
  68.         TESelView(hTE);
  69.         if (vScrollBar!=0L)
  70.             AdjustVScrollBar(vScrollBar, hTE);
  71.     }
  72.     
  73.     DisposeHandle(scrapHandle);
  74.     SetWindowLastFindPosition(theWindow, (**hTE).selStart);
  75.     ResetHiliteRgn(theWindow);
  76. }
  77.  
  78. void GenericClear(WindowPtr theWindow)
  79. {
  80.     TEHandle        hTE;
  81.     ControlHandle    vScrollBar;
  82.     
  83.     hTE=GetWindowTE(theWindow);
  84.     vScrollBar=GetWindowVScrollBar(theWindow);
  85.     if (AnyHighlightedQQ(theWindow))
  86.         SetWindowIsModified(theWindow, TRUE);
  87.     TEDelete(hTE);
  88.     if (vScrollBar!=0L)
  89.         AdjustForEndScroll(vScrollBar, hTE);
  90.     TESelView(hTE);
  91.     if (vScrollBar!=0L)
  92.         AdjustVScrollBar(vScrollBar, hTE);
  93.     SetWindowLastFindPosition(theWindow, (**hTE).selStart);
  94.     ResetHiliteRgn(theWindow);
  95. }
  96.  
  97. void GenericSelectAll(WindowPtr theWindow)
  98. {
  99.     TEHandle        hTE;
  100.     ControlHandle    vScrollBar;
  101.     
  102.     hTE=GetWindowTE(theWindow);
  103.     vScrollBar=GetWindowVScrollBar(theWindow);
  104.     TESetSelect(0, 32767, hTE);
  105.     TESelView(hTE);
  106.     if (vScrollBar!=0L)
  107.         AdjustVScrollBar(vScrollBar, hTE);
  108.     SetWindowLastFindPosition(theWindow, (**hTE).selStart);
  109.     ResetHiliteRgn(theWindow);
  110. }
  111.